%polarization angle (ute)
% latest date 26.11.2004
% data is the psd matrix
function[alphaE,alphaB] = polangle(SPMatrix,nfrq),

j = sqrt(-1);
A = size(SPMatrix);
    
    for i = 1:A(2),
        data = squeeze(SPMatrix(nfrq,i,:,:));
        HxHx = data(1,1);
HyHy = data(2,2);
ExEx = data(4,4);
EyEy = data(5,5);
HxHy = data(2,1) - j*data(1,2);
ExEy = data(5,4) - j*data(4,5);

alphaE(i) = atan(2*real(ExEy)/(ExEx-EyEy));
alphaB(i) = atan(2*real(HxHy)/(HxHx-HyHy));
end;


